
package com.liao.badminton.controller;

import com.github.pagehelper.PageInfo;
import com.liao.badminton.code.*;
import com.liao.badminton.dto.StipulationLevelAddsDto;
import com.liao.badminton.dto.StipulationLevelDto;
import com.liao.badminton.service.StipulationLevelService;
import com.liao.badminton.vo.StipulationLevelListVo;
import com.liao.badminton.vo.StipulationLevelVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import com.liao.badminton.code.validation.Delete;
import com.liao.badminton.code.validation.Insert;
import com.liao.badminton.code.validation.Update;
import com.liao.badminton.code.validation.FindDetail;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import java.util.List;

/**
* @author liaocheng
* @date 2024-11-08
* description:等级划分规则表
*/
@RestController
@RequestMapping(value = "/stipulationLevel")
// @PreAuthorize("@ss.hasPermission('stipulationLevel')")//权限管理;
public class StipulationLevelController {

  //  private static  Logger logger= LoggerFactory.getLogger(StipulationLevelController.class);

    @Autowired
    private StipulationLevelService stipulationLevelService;




    /**
    * 批量 添加 等级划分规则
    */
    @RequestMapping(value = "/add")
    @PreAuthorize("@ss.hasPermission('stipulationLevel:add')")//权限管理;
    public ResponseRest<Long> add(@RequestBody @Valid  List<StipulationLevelAddsDto> stipulationLevels)throws ProjectException{
        return stipulationLevelService.saveStipulationLevel(stipulationLevels);
    }
    /**
    * 批量删除
    */
    @RequestMapping(value = "/deletes")
    @PreAuthorize("@ss.hasPermission('stipulationLevel:deletes')")//权限管理;
    public ResponseRest<Boolean> deletes(@RequestBody @Validated(Delete.class) StipulationLevelDto param)throws ProjectException{
        return stipulationLevelService.deletesStipulationLevel(param);
    }
    /**
    * 修改stipulationLevel
    */
    @RequestMapping(value = "/update")
    @PreAuthorize("@ss.hasPermission('stipulationLevel:update')")//权限管理;
    public ResponseRest<Boolean> update(@RequestBody @Validated(Update.class) StipulationLevelDto param)throws ProjectException{
        return stipulationLevelService.updateStipulationLevel(param);
    }

    @RequestMapping(value = "/findDetail")
    @PreAuthorize("@ss.hasPermission('StipulationLevel:findDetail')")//权限管理;
    public ResponseRest<StipulationLevelVo> findDetail(@RequestBody @Validated(FindDetail.class) StipulationLevelDto param) throws ProjectException {
      return stipulationLevelService.findDetail(param);
    }
    /**
    * 分页查询列表
     *
    */
    @RequestMapping(value = "/list")
    @PreAuthorize("@ss.hasPermission('stipulationLevel:list')")//权限管理;
    public ResponseRest<PageInfo<StipulationLevelVo>> list(@RequestBody PageParam<StipulationLevelDto> body) throws ProjectException{
      return   stipulationLevelService.findStipulationLevelByPageParam(body);
    }
    /**
     * 分页查询列表
     *
     */
    @RequestMapping(value = "/findListByParam")
    @PreAuthorize("@ss.hasPermission('stipulationLevel:findListByParam')")//权限管理;
    public ResponseRest<StipulationLevelListVo> list(@RequestBody StipulationLevelDto body) throws ProjectException{
        return   stipulationLevelService.findListByParam(body);
    }


}
